﻿Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Imports System.Web

Partial Public Class Formulario_web15
    Inherits System.Web.UI.Page


    Dim ocnTrabajoFinal As New CapaNegocio.TrabajoFinal()


    Protected Sub ButtonConsulta_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonConsulta.Click
        'Lo carga aqui al Source para que no aparezca en el Load
        CrystalReportViewer1.ReportSourceID = "CrystalReportSource1"
        Try
            Dim ParamFields As ParameterFields = Me.CrystalReportViewer1.ParameterFieldInfo
            Dim p_desde As New ParameterField
            Dim p_hasta As New ParameterField
            p_desde.Name = "@paramDesdeFecha"
            p_hasta.Name = "@paramHastaFecha"
            Dim p_desde_Value As New ParameterDiscreteValue
            Dim p_hasta_Value As New ParameterDiscreteValue
            p_desde_Value.Value = CDate(Me.FechaDesde.Text)
            p_hasta_Value.Value = CDate(Me.FechaHasta.Text)
            p_desde.CurrentValues.Add(p_desde_Value)
            p_hasta.CurrentValues.Add(p_hasta_Value)

            ParamFields.Add(p_desde)
            ParamFields.Add(p_hasta)

            CrystalReportViewer1.RefreshReport()

        Catch ex As Exception
            Session.Add("exError", ex)
            Response.Redirect("ManejarError.aspx")
        End Try


    End Sub

    Private Sub FechaHasta_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles FechaHasta.Init
        Me.FechaHasta.Text = DateTime.Now.ToString("d")
    End Sub

End Class